package com.lzp.wechat.controller;

import com.lzp.wechat.service.WeiXinUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(tags = "微信用户信息接口")
public class WeiXinUserInfoController {

    @Autowired
    private WeiXinUserInfoService weiXinUserInfoService;

    @GetMapping("/getUserInfoByOpenid")
    @ApiOperation(value = "根据openid获取用户信息", notes = "根据openid获取用户信息")
    @ApiImplicitParam(paramType = "query", name = "openid", value = "微信id", required = true, dataType = "String")
    public String getUserInfoByOpenId(@RequestParam("openid") String openid) {
        return weiXinUserInfoService.getUserInfoByOpenId(openid);
    }

    @GetMapping("/getUserInfoByCode")
    @ApiOperation(value = "根据code获取用户信息", notes = "根据code获取用户信息")
    public String getUserInfoByCode(@RequestParam("code") String code) {
        return weiXinUserInfoService.getUserInfoByCode(code);
    }

}
